<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

<!DOCTYPE html>
<html lang="en">
<head>
<title><s:message code="app.title" /></title>
<%@ include file="Include.jsp"%>
<script type="text/javascript">
	
	$(document).ready(function() {
		var oTable = $('#containerTable').dataTable( {
			 	"bDestroy": true,
		        "bProcessing": false,
		        "iDisplayLength": 10,
		        "bFilter": true,
		        "bLengthChange": false,
		        "aoColumnDefs": [
		          { 'bSortable': false, 'aTargets': [5] }
		       	]
		 	} );
		
		$('#addContainer').click(function(){
			$('#containerListForm').attr('action','AddContainer');
			$('#containerListForm').attr('method','get');
			$('#containerListForm').submit();
		});
		
	});
	
	function edit(containerid){
		$('#containerEditForm').attr('action','EditContainer?containerId='+containerid);
		
		$('#containerId').val(containerid);
		
		$('#containerEditForm').attr('method','get');
		$('#containerEditForm').submit();
	}
	
</script>
</head>
<body>
	<div class="container">
		<%@ include file="Menu.jsp"%>
		<h2><s:message code="containerForm.listheader" /></h2>
		<hr>
		<form:form id="containerEditForm" >
			<input type="hidden" id="containerId" name="containerId" />
		</form:form>
		<form:form id="containerListForm" >
		<table class="table table-hover table-bordered" id="containerTable">
				<thead>
					<tr>
						<th><s:message code="containerForm.containerno" /></th>
						<th><s:message code="containerForm.containertypeid" /></th>
						<th><s:message code="containerForm.stuffingdate" /></th>
						<th><s:message code="containerForm.customsealno" /></th>
						<th><s:message code="containerForm.agentsealno" /></th>
						<th><s:message code="app.action" /></th>
					</tr>
				</thead>
				
				<tbody>
					<c:forEach items="${containerList}" var="container" >
						<tr>
							<td>
								<c:out value="${container.containerno}"></c:out>
							</td>
							<td>
								<c:out value="${container.containertypeid}"></c:out>
							</td>
							<td>
								<c:out value="${container.stuffingdate}"></c:out>
							</td>
							<td>
								<c:out value="${container.customsealno}"></c:out>
							</td>
							<td>
								<c:out value="${container.agentsealno}"></c:out>
							</td>
							<td>
								<a href="#" onclick="javascript: edit('${container.containerid}');" >Edit</a>
							</td>
						</tr>
					</c:forEach>
				</tbody>
		</table>
		<br>
		<br>
		<br>
		<button class="btn btn-primary" type="button" id="addContainer"><s:message code="containerForm.addheader" /></button>
		</form:form>
		 <%@ include file="Footer.jsp"%>
	</div>
</body>
</html>